using System;
using System.Collections;

namespace Jonathan.XhtmlRichTextBox
{
    /// <summary>
    /// Summary description for RtfFontTable.
    /// </summary>
    public class RtfFontTable
    {
        private int numberOfFonts = 0;
        private string fonttbl;
        private Hashtable loadedFonts = new Hashtable();

        public RtfFontTable ()
        {
            //
            // TODO: Add constructor logic here
            //

            fonttbl = "{\\fonttbl{\\f0\\froman Times New Roman;}";
        }

        public int UseFont (string fontName)
        {
            if (loadedFonts.Contains(fontName))
            {
                return (int)loadedFonts[fontName];
            }
            else
            {
                fonttbl += "{\\f" + (++numberOfFonts) + "\\fnil " + fontName + ";}";
                loadedFonts.Add(fontName, numberOfFonts);
                return numberOfFonts;
            }
        }


        public override string ToString ()
        {
            return fonttbl + "}";
        }
    }
}
